<template>
	<el-table :data="documents" style="width: 70%">
	    <el-table-column prop="documentName" label="文档名称" width="180" />
	    <el-table-column prop="userId" label="文档上传者" width="120" />
		<el-table-column prop="documentClass" label="文档分类" width="120"/>
		<el-table-column prop="documentState" label="文档状态" width="120"/>
	    <el-table-column prop="documentDate" label="文档上传日期" width="120"/>

		<el-table-column   label="文档链接" >

 <template  #default="scope">
    <a :href="scope.row.documentContent" target="_blank" class="buttonText">{{scope.row.documentContent}}</a>
  </template>

</el-table-column>
	</el-table>

	<!-- 文档查看提示框 -->
	<el-dialog v-model="documentDialogVisible" title="文档信息">

		<el-button type="primary" @click="documentDialogVisible=false">确认</el-button>
	</el-dialog>

	<!-- 文档提示框 -->
	<el-dialog v-model="documentUpdateDialog" title="文档">

	</el-dialog>

</template>

<script>
	import qs from 'qs'
	export default {
			data() {
				return {
					documents:[],
					document:{},
					documentDialogVisible:false,
					documentUpdateDialog:false,
					num:0,
					documentuser:{}
				}
			},
			methods: {
				showDocument(index) {
					this.num=index
					this.documentuser.documentId=this.documents[index].documentId
					let that=this
					let s=qs.stringify(that.documentState)
					this.$axios.get("http://localhost:8080/documentuser/show?"+s).then(function(res){
						that.documents[index].users=res.data
						that.documentDialogVisible=true
					})
				},

				updateDocumentSubmit(){
					let that=this
					let s=qs.stringify(that.documents[that.num])
					this.$axios.get("http://localhost:8080/document/documentupdate?"+s).then(function(res){
						that.documentUpdateDialog=false
					})

				}

			},
			created() {
				let u=JSON.parse(sessionStorage.getItem("user"))
				let that=this
				that.document.documentState="公开"
				let str=qs.stringify(that.document)
				this.$axios.get("http://localhost:8080/document/documentshow2?"+str).then(function(res){
					that.documents=res.data
				})
			}
	}
</script>

<style>
</style>
